<?php
	ob_start();
	include("connection/connection.php");
	$id = $_GET['id'];
	//print_r($id);
	$query = "SELECT * FROM productdetails WHERE id=$id";
	$result = mysql_query($query);
	list($id,$cateID,$groupID,$productname,$imgpath,$productDetail,$productView,$productQty,$position,$dateCreated,$state) = mysql_fetch_array($result);
	//print_r($productname); die();
	$download = $download +1;
	$query = "UPDATE productdetails SET download = $download WHERE id = $id";
	mysql_query($query) or die(mysql_error());
	
	$linkFile = substr($imgpath,3);
	
	// Download giau link
	$filename = $linkFile;
	$file = fopen($filename, "rb");
	
	header("Content-type: application/octet-stream");
	header('Content-disposition: attachment; filename="'.basename($filename).'"');
	header("Content-length: ".filesize($filename));
	
	fpassthru($file);
	fclose($file);
?>